package com.example.demo.TakeMaterial.controller;

import com.example.demo.common.ResponseData;
import com.example.demo.TakeMaterial.dto.DeliveryInfo;
import com.example.demo.TakeMaterial.service.OutFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/deliveryManagement/out-form")
@PreAuthorize("hasAnyAuthority('1','2','4','5')")
@CrossOrigin(origins = {"*"})
public class OutFormController {
    @Autowired
    private OutFormService outFormService;

    // 所有出库记录
    @GetMapping("/selectAll")
    public ResponseData selectAll() {
        return outFormService.selectAll();
    }

    // 查询本月出库记录
    @GetMapping("/selectThisMonth")
    public ResponseData selectThisMonth() {
        return outFormService.selectThisMonth();
    }

    // 处理出库请求
    @PostMapping("/delivery")
    public ResponseData delivery(@RequestBody DeliveryInfo deliveryInfo) {
        return outFormService.deliver(deliveryInfo);
    }
}
